import React from "react"
import Dynamic from '@/api/dynamic'
import { Button, Input, DatePicker, Select, Modal, Cascader, Spin, Upload, Table, Form, Steps, Row, Col, Tabs, Card, Radio, message, Checkbox } from 'antd';
let configs =
{
  1: {//传输任务
    id: 'ref1',
    searchApiId: 'DMT_1001',
    key: 'tran_task_id',
    extraPropsApiid: 'DMT_1001',//查询列表 apiid
    editapiID: "DMT_MNG_01",//编辑apiid
    editapiParamMng_id: "DMT_1001_1",//编辑form表单 参数id
    addApiId: 'DMT_1001_1',//新增apiid
    updateApiId: 'DMT_1001_2',//更新apiid
    detailApiId: 'DMT_1001_5',//详情apiid
    columns: [
      {
        title: '操作',
        align: 'left',
        dataIndex: 'scan',
        key: 'scan',
        width: '180px',
        fixed: 'right',
        render: (text, record, index) => {
          return <div>
            <Button className="btn" onClick={() => configs['1']['edit'](record.tran_task_id)} size="small">编辑</Button>
            {
              record.status == '2' && <Button style={{ marginLeft: '10px' }} onClick={() => configs['1']['start'](record.tran_task_id)} className="btn" size="small">启动</Button>
            }
            <Button style={{ marginLeft: '10px' }} className="btn" onClick={() => configs['1']['del'](record.tran_task_id)} size="small">删除</Button>
          </div>
        }
      }
    ],
    ref: null,

    // 添加
    edit: (id) => {
      window['ref1'].AddComRef.current.init(id);
    },
    del: (id) => {
      Modal.confirm({
        title: '确认删除？',

        onOk() {
          // Role.roleDel({
          //   roleid:record.roleid,
          //   isFormData:true
          // }).then(()=>{
          //   tableRef.current.update();
          // })
          Dynamic.DynamicExecute({
            apiID: 'DMT_1001_3',
            apiParam: {
              tran_task_id: id
            }
          }).then((res) => {
            window['ref1'].tableRef.current.update();
          })
        },
        onCancel() {
        },
      });
    },
    start: (id) => {
      Dynamic.DynamicExecute({
        apiID: 'DMT_1001_4',
        apiParam: {
          tran_task_id: id
        }
      }).then((res) => {
        window['ref1'].tableRef.current.update();
      })
    }
  },
  2: {//数据源
    id: 'ref2',
    searchApiId: 'DMT_0001',
    key: 'tran_task_id',
    extraPropsApiid: 'DMT_0001',//查询列表 apiid
    editapiID: "DMT_MNG_01",//编辑apiid
    editapiParamMng_id: "DMT_0001_1",//编辑form表单 参数id
    addApiId: 'DMT_0001_1',//新增apiid
    updateApiId: 'DMT_0001_2',//更新apiid
    detailApiId: 'DMT_0001_4',//详情apiid
    columns: [
      {
        title: '操作',
        align: 'left',
        dataIndex: 'scan',
        key: 'scan',
        width: '180px',
        fixed: 'right',
        render: (text, record, index) => {
          return <div>
            <Button className="btn" onClick={() => configs['2']['edit'](record.pid)} size="small">编辑</Button>
            <Button className="btn" style={{ marginLeft: '10px' }} onClick={() => configs['2']['del'](record.pid)} size="small">删除</Button>
          </div>
        }
      }
    ],
    ref: null,
    // 添加
    edit: (id) => {
      window['ref2'].AddComRef.current.init(id);
    },
    del: (id) => {
      Modal.confirm({
        title: '确认删除？',

        onOk() {
          // Role.roleDel({
          //   roleid:record.roleid,
          //   isFormData:true
          // }).then(()=>{
          //   tableRef.current.update();
          // })
          Dynamic.DynamicExecute({
            apiID: 'DMT_0001_3',
            apiParam: {
              pid: id
            }
          }).then((res) => {
            window['ref2'].tableRef.current.update();
          })
        },
        onCancel() {
        },
      });
    }
  },
  3: {//捕获任务
    id: 'ref3',
    searchApiId: 'DMT_1002',
    key: 'cap_task_id',
    extraPropsApiid: 'DMT_1002',//查询列表 apiid
    editapiID: "DMT_MNG_01",//编辑apiid
    editapiParamMng_id: "DMT_1002_1",//编辑form表单 参数id
    addApiId: 'DMT_1002_1',//新增apiid
    updateApiId: 'DMT_1002_5',//更新apiid
    detailApiId: 'DMT_1002_7',//详情apiid
    columns: [
      {
        title: '操作',
        align: 'left',
        dataIndex: 'scan',
        key: 'scan',
        width: '180px',
        fixed: 'right',
        render: (text, record, index) => {
          return <div>
            <Button className="btn" onClick={() => configs['3']['edit'](record.cap_task_id)} size="small">编辑</Button>
            <Button className="btn" style={{ marginLeft: '10px' }} onClick={() => configs['3']['del'](record.cap_task_id)} size="small">删除</Button>
          </div>
        }
      }
    ],
    ref: null,
    // 添加
    edit: (id) => {
      window['ref3'].AddComRef.current.init(id);
    },
    del: (id) => {
      Modal.confirm({
        title: '确认删除？',

        onOk() {
          // Role.roleDel({
          //   roleid:record.roleid,
          //   isFormData:true
          // }).then(()=>{
          //   tableRef.current.update();
          // })
          Dynamic.DynamicExecute({
            apiID: 'DMT_1002_6',
            apiParam: {
              cap_task_id: id
            }
          }).then((res) => {
            window['ref3'].tableRef.current.update();
          })
        },
        onCancel() {
        },
      });
    }
  },
  4: {//清洗规则管理
    id: 'ref4',
    searchApiId: 'DMT_A001',
    key: 'cap_task_id',
    extraPropsApiid: 'DMT_A001',//查询列表 apiid
    editapiID: "DMT_MNG_01",//编辑apiid
    editapiParamMng_id: "DMT_A001_01",//编辑form表单 参数id
    addApiId: 'DMT_A001_01',//新增apiid
    updateApiId: 'DMT_A001_02',//更新apiid
    detailApiId: 'DMT_A001_04',//详情apiid
    columns: [
      {
        title: '操作',
        align: 'left',
        dataIndex: 'scan',
        key: 'scan',
        width: '140px',
        fixed: 'right',
        render: (text, record, index) => {
          return <div>
            <Button className="btn" onClick={() => configs['4']['edit'](record.rule_id)} size="small">编辑</Button>
            <Button className="btn" style={{ marginLeft: '10px' }} onClick={() => configs['4']['del'](record.rule_id)} size="small">删除</Button>
          </div>
        }
      }
    ],
    ref: null,
    // 添加
    edit: (id) => {
      window['ref4'].AddComRef.current.init(id);
    },
    del: (id) => {
      Modal.confirm({
        title: '确认删除？',

        onOk() {
          // Role.roleDel({
          //   roleid:record.roleid,
          //   isFormData:true
          // }).then(()=>{
          //   tableRef.current.update();
          // })
          Dynamic.DynamicExecute({
            apiID: 'DMT_A001_03',
            apiParam: {
              rule_id: id
            }
          }).then((res) => {
            message.success('删除成功');
            window['ref4'].tableRef.current.update();
          })
        },
        onCancel() {
        },
      });
    }
  },
  5: {//任务监控
    id: 'ref5',
    searchApiId: 'DMT_B002_01',
    key: 'cap_task_id',
    extraPropsApiid: 'DMT_B001',//查询列表 apiid
    editapiID: "DMT_B001",//编辑apiid
    editapiParamMng_id: "DMT_A001_01",//编辑form表单 参数id
    addApiId: 'DMT_A001_01',//新增apiid
    updateApiId: 'DMT_A001_02',//更新apiid
    detailApiId: 'DMT_A001_04',//详情apiid
    columns: [
      {
        title: '操作',
        align: 'left',
        dataIndex: 'scan',
        key: 'scan',
        width: '180px',
        fixed: 'right',
        render: (text, record, index) => {
          return <div>
            <Button className="btn" onClick={() => configs['4']['edit'](record.rule_id)} size="small">编辑</Button>
            <Button className="btn" style={{ marginLeft: '10px' }} onClick={() => configs['4']['del'](record.rule_id)} size="small">删除</Button>
          </div>
        }
      }
    ],
    ref: null,
    // 添加
    edit: (id) => {
      window['ref5'].AddComRef.current.init(id);
    },
    del: (id) => {
      Modal.confirm({
        title: '确认删除？',

        onOk() {
          // Role.roleDel({
          //   roleid:record.roleid,
          //   isFormData:true
          // }).then(()=>{
          //   tableRef.current.update();
          // })
          Dynamic.DynamicExecute({
            apiID: 'DMT_A001_03',
            apiParam: {
              rule_id: id
            }
          }).then((res) => {
            window['ref4'].tableRef.current.update();
          })
        },
        onCancel() {
        },
      });
    }
  }
}

export default configs;